package org.bbelovic.devel.algorithms.recursive;

public class Fibonacci implements RecursiveAlgorithm<Long, Long> {

	private final long n;
	public Fibonacci(final long n) {
		this.n = n;
	}

	@Override
	public Long compute(Long input) {
		return fibonacci(input);
	}
	
	@Override
	
	public Long compute() {
		return this.compute(this.n);
	}
	
    private Long fibonacci(final Long n) {
        if (n == 0) return 0L;
        else if (n == 1) return 1L;
        else return fibonacci(n-1) + fibonacci(n-2);
    }
}
